import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:quintesson/utils/qr_scanner.dart';

import 'login/forget_pwd.dart';
import 'login/login.dart';
import 'login/loginmain.dart';
import 'login/register.dart';
import 'main/mainpage.dart';
import 'main.dart';
import 'utils/img_picker.dart';

class Routes {
  static Router router;
  static String rootPage = '/';
  static String login = '/login';
  static String loginMain = '/loginMain';
  static String mainPage = '/mainPage';
  static String myImagePicker = '/myImagePicker';
  static String qrScanner = 'utils/qr_scanner';
  static String changePass = '/changePass';
  static String register = '/register';
  static String forget_pwd = '/forget_pwd';

  static var loginHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Login();
  });
  static var qrScannerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
        return QRScanner();
      });

  static var loginMainHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoginMain();
  });

  static var registerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Register();
  });


  static var forget_pwdHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ForgetPwd();
  });

  static var mainPageHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MainPage();
  });

  static var myImagePickerHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String type = params["type"]?.first;
    return MyImagePicker(type: type);
  });

  static void configureRoutes(Router router) {
    router.define(rootPage,
        handler: Handler(handlerFunc: (context, params) => PageRoot()));

    router.define(forget_pwd, handler: forget_pwdHandler);
    router.define(login, handler: loginHandler);
    router.define(loginMain, handler: loginMainHandler);
    router.define(register, handler: registerHandler);
    router.define(mainPage, handler: mainPageHandler);
    router.define(myImagePicker, handler: myImagePickerHandler);
    router.define(qrScanner, handler: qrScannerHandler);
    Routes.router = router;
  }
}
